<!--{template header}-->

<!--{if $_GET['op'] == 'edit'}-->

<div id="$pid" <!--{if !$_SGLOBAL[inajax]}-->class="c_form"<!--{else}-->class="inajax"<!--{/if}-->>
<!--{if $_SGLOBAL[inajax]}-->
<h1>编辑</h1>
<a href="javascript:hideMenu();" class="float_del" title="关闭">关闭</a>
<div class="popupmenu_inner">
<!--{/if}-->
	<form id="editpostform_{$pid}" name="editpostform_{$pid}" method="post" action="cp.php?ac=thread&op=edit&pid=$pid&tagid=$tagid">
		<table>
			<tr>
				<th style="vertical-align: top;"><label for="message">内容：</label></th>
				<td>
					<a href="###" id="face_{$pid}" onclick="showFace(this.id, 'message_{$pid}');"><img src="image/facelist.gif" align="absmiddle" /></a>
					<img src="image/zoomin.gif" onmouseover="this.style.cursor='pointer'" onclick="zoomTextarea('message', 1)">
					<img src="image/zoomout.gif" onmouseover="this.style.cursor='pointer'" onclick="zoomTextarea('message', 0)"><br/>
					<textarea id="message_{$pid}" name="message"  style="width:98%;" onkeydown="ctrlEnter(event, 'posteditsubmit_btn');" <!--{if $post['isthread']}-->rows="18"<!--{else}-->rows="8"<!--{/if}-->>$post[message]</textarea>
				</td>
			</tr>
			<tbody id="editwebimg">
				<tr>
					<th>图片：</th>
					<td>
						<input class="t_input" type="text" onfocus="if(this.value == 'http://')this.value='';" onblur="if(this.value=='')this.value='http://'" name="pics[]" value="http://" size="40" />&nbsp;
						<a href="javascript:;" onclick="insertWebImg(this.previousSibling.previousSibling)">插入</a> &nbsp;
						<a href="javascript:;" onclick="delRow(this, 'editwebimg')">删除</a>
					</td>
				</tr>
			</tbody>
			<tr>
				<th>&nbsp;</th>
				<td>
					<a href="javascript:;" onclick="copyRow('editwebimg')">+增加图片</a> <span class="gray">只支持 .jpg、.gif、.png为结尾的URL地址</span>
				</td>
			</tr>
			<tr>
				<th>&nbsp;</th>
				<td>
				<input type="hidden" name="pid" value="$pid">
				<input type="hidden" name="refer" value="$_SGLOBAL[refer]" />
				<input type="hidden" name="posteditsubmit" value="true" />
				<!--{if $_SGLOBAL[inajax]}-->
				<input type="button" name="posteditsubmit_btn" id="posteditsubmit_btn" value="提交" class="submit" onclick="ajaxpost('editpostform_{$pid}', '$pid', 'post_edit')" />&nbsp;
				<!--{else}-->
				<input type="submit" name="posteditsubmit_btn" id="posteditsubmit_btn" value="提交" class="submit" />&nbsp;
				<!--{/if}-->
				</td>
			</tr>
		</table>
	<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
	</form>
<!--{if $_SGLOBAL[inajax]}--></div><!--{/if}-->
</div>

<!--{elseif $_GET['op'] == 'delete'}-->

<div id="$pid" <!--{if !$_SGLOBAL[inajax]}-->class="inpage"<!--{/if}-->>
<form id="delete_postform_{$pid}" name="delete_postform_{$pid}" method="post" action="cp.php?ac=thread&op=delete&pid=$pid&tagid=$tagid">
	<h1>确定删除指定的帖子吗？</h1>
	<p class="btn_line">
		<input type="hidden" name="refer" value="$_SGLOBAL[refer]" />
		<!--{if $_SGLOBAL[inajax]}-->
		<input type="hidden" name="postdeletesubmit" value="true" />
		<input type="button" name="postdeletesubmit_btn" value="提交" class="submit" onclick="ajaxpost('delete_postform_{$pid}', '$pid', 'post_delete')" />&nbsp;
		<button name="btncancel" type="button" class="button" onclick="hideMenu()">取消</button>
		<!--{else}-->
		<input type="submit" name="postdeletesubmit" value="提交" class="submit" />&nbsp;
		<!--{/if}-->
	</p>
<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" /></form>
</div>

<!--{elseif $_GET['op'] == 'reply'}-->

<div id="$post[pid]" <!--{if !$_SGLOBAL[inajax]}-->class="inpage"<!--{else}-->class="inajax"<!--{/if}-->>
<!--{if $_SGLOBAL[inajax]}-->
	<h1>回复</h1>
	<a href="javascript:hideMenu();" class="float_del" title="关闭">关闭</a>
	<div class="popupmenu_inner">
<!--{/if}-->
<form id="reply_postform_{$post[pid]}" name="reply_postform_{$post[pid]}" method="post" action="cp.php?ac=thread">
	<table>
		<tr>
			<th><label for="message">内容：</label></th>
			<td>
				<a href="###" id="face_{$post[pid]}" onclick="showFace(this.id, 'message_{$post[pid]}');"><img src="image/facelist.gif" align="absmiddle" /></a>
				<img src="image/zoomin.gif" onmouseover="this.style.cursor='pointer'" onclick="zoomTextarea('message', 1)">
				<img src="image/zoomout.gif" onmouseover="this.style.cursor='pointer'" onclick="zoomTextarea('message', 0)"><br/>
				<textarea id="message_{$post[pid]}" name="message" onkeydown="ctrlEnter(event, 'postsubmit');" rows="8" cols="70"></textarea>
			</td>
		</tr>
		<tbody id="replybimg">
			<tr>
				<td>图片：</td>
				<td>
					<input class="t_input" type="text" name="pics[]" onfocus="if(this.value == 'http://')this.value='';" onblur="if(this.value=='')this.value='http://'" value="http://" size="30" />&nbsp;
					<a href="javascript:;" onclick="insertWebImg(this.previousSibling.previousSibling)">插入</a> &nbsp;
					<a href="javascript:;" onclick="delRow(this, 'replybimg')">删除</a>
				</td>
			</tr>
		</tbody>
		<tr>
			<th>&nbsp;</th>
			<td>
				<a href="javascript:;" onclick="copyRow('replybimg')">+增加图片</a> <span class="gray">只支持 .jpg、.gif、.png为结尾的URL地址</span>
			</td>
		</tr>
	
		<tr>
			<td>&nbsp;</td>
			<td>
				<input type="hidden" name="refer" value="$_SGLOBAL[refer]" />
				<input type="hidden" name="tid" value="$post[tid]" />
				<input type="hidden" name="pid" value="$post[pid]" />
				<!--{if $_SGLOBAL[inajax]}-->
				<input type="hidden" name="postsubmit" value="true" />
				<input type="button" name="postsubmit_btn" id="postsubmit" value="回复" class="submit" onclick="ajaxpost('reply_postform_{$post[pid]}', '$post[pid]', 'post_add')" />
				<!--{else}-->
				<input type="submit" name="postsubmit" id="postsubmit" value="回复" class="submit" />
				<!--{/if}-->
			</td>
		</tr>
	</table>
<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
</form>
<!--{if $_SGLOBAL[inajax]}--></div><!--{/if}-->
</div>

<!--{else}-->

<script language="javascript" src="image/editor/editor_function.js"></script>
<script type="text/javascript">
	function validate(obj) {
	    var subject = $('subject');
	    if (subject) {
	    	var slen = strlen(subject.value);
	        if (slen < 1 || slen > 80) {
	            alert("标题长度(1~80字符)不符合要求");
	            subject.focus();
	            return false;
	        }
	    }

	    if($('seccode')) {
			var code = $('seccode').value;
			var x = new Ajax();
			x.get('cp.php?ac=common&op=seccode&code=' + code, function(s){
				s = trim(s);
				if(s.indexOf('succeed') == -1) {
					alert(s);
					$('seccode').focus();
	           		return false;
				} else {
					uploadEdit(obj);
					return true;
				}
			});
	    } else {
	    	uploadEdit(obj);
	    	return true;
	    }
	}
	function edit_album_show(id) {
		var obj = $('uchome-edit-'+id);
		if(id == 'album') {
			$('uchome-edit-pic').style.display = 'none';
		}
		if(id == 'pic') {
			$('uchome-edit-album').style.display = 'none';
		}
		if(obj.style.display == '') {
			obj.style.display = 'none';
		} else {
			obj.style.display = '';
		}
	}
</script>


<h2 class="title"><img src="image/app/mtag.gif" />群组</h2>
<div class="tabs_header">
	<ul class="tabs">
	<!--{if $thread}-->
		<li class="active"><a href="cp.php?ac=thread&op=edit&pid=$post[pid]"><span>编辑话题</span></a></li>
		<li><a href="space.php?do=mtag&tagid=$thread[tagid]&view=list"><span>返回讨论区</span></a></li>
	<!--{else}-->	
		<li class="active"><a href="cp.php?ac=thread"><span>发表新话题</span></a></li>
		<li><a href="space.php?do=thread&view=me"><span>返回我的话题</span></a></li>
	<!--{/if}-->
	</ul>
</div>


<style>
	.userData {behavior:url(#default#userdata);}
</style>

<div class="c_form">
	<form method="post" action="cp.php?ac=thread" enctype="multipart/form-data">
		<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
		<!--{if !$tagid}-->
			<tr>
				<td>
				<select name="tagid" id="tagid">
				<!--{loop $mtaglist $fieldid $values}-->
				<!--{loop $values $value}-->
					<option value="$value[tagid]">[{$value[fieldtitle]}] $value[tagname]</option>>
				<!--{/loop}-->
				<!--{/loop}-->
				</select>
				<a href="cp.php?ac=mtag">创建新群组</a>
				</td>
			</tr>
		<!--{else}-->
			<tr>
				<td>$mtag[tagname]<!--{if !$thread}--> [<a href="cp.php?ac=thread">切换</a>]<!--{/if}-->
					<input type="hidden" name="tagid" value="$tagid" />
				</td>
			</tr>
		<!--{/if}-->
			<tr>
				<td><input type="text" class="t_input" id="subject" name="subject" value="$thread[subject]" size="60" /></td>
			</tr>
			<tr>
				<td>
				<textarea class="userData" name="message" id="uchome-ttHtmlEditor" style="height:100%;width:100%;display:none;border:0px">$post[message]</textarea>
				<iframe src="editor.php?charset=$_SC[charset]&allowhtml=<!--{eval echo checkperm('allowhtml')}-->" name="uchome-ifrHtmlEditor" id="uchome-ifrHtmlEditor" scrolling="no" border="0" frameborder="0" style="width:100%;border: 1px solid #C5C5C5;" height="400"></iframe>
				</td>
			</tr>
		</table>
		<!--{if checkperm('seccode')}-->
		<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
			<!--{if $_SCONFIG['questionmode']}-->
			<tr>
				<td>
					<p>请回答验证问题</p>
					<p><!--{eval question();}--></p>
					<input type="text" id="seccode" name="seccode" value="" size="15" class="t_input" />
				</td>
			</tr>
			<!--{else}-->
			<tr>
				<td>
					<p>请填写验证码</p>
					<script>seccode();</script>
					<p>请输入上面的4位字母或数字，看不清可<a href="javascript:updateseccode()">更换一张</a></p>
					<input type="text" id="seccode" name="seccode" value="" size="15" class="t_input" />
				</td>
			</tr>
			<!--{/if}-->
		</table>
		<!--{/if}-->
		<input type="hidden" name="tid" value="$thread[tid]" />
		<input type="hidden" name="threadsubmit" value="true" />
		<input type="button" id="threadbutton" name="threadbutton" value="提交发布" onclick="validate(this);" style="display: none;" />
		<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
	</form>
	<!--{if !$thread['uid'] || $thread['uid']==$_SGLOBAL['supe_uid']}-->
	<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
		<tr><td>
		<input type="button" name="clickbutton[]" value="上传图片" class="button" onclick="edit_album_show('pic')">
		<input type="button" name="clickbutton[]" value="插入图片" class="button" onclick="edit_album_show('album')">
		</td></tr>
	</table>
	<!--{/if}-->
	<table cellspacing="4" cellpadding="4" width="100%" id="uchome-edit-pic" class="infotable" style="display:none;">
		<tr>
			<td>
				<strong>选择图片</strong>: 
				<table summary="Upload" cellspacing="2" cellpadding="0">
					<tbody id="attachbodyhidden" style="display:none">
						<tr>
							<td>
								<form method="post" id="upload" action="cp.php?ac=upload" enctype="multipart/form-data" target="uploadframe" style="background: transparent;">
									<input type="file" name="attach" style="border: 1px solid #CCC;" />
									<span id="localfile"></span>
									<input type="hidden" name="uploadsubmit" id="uploadsubmit" value="true" />
									<input type="hidden" name="albumid" id="albumid" value="0" />
									<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
								</form>
							</td>
						</tr>
					</tbody>
					<tbody id="attachbody"></tbody>
				</table>
				<strong>存储相册</strong>: 
				<table cellspacing="2" cellpadding="0">
					<tr>
						<td>
							<select name="albumid" id="uploadalbum" onchange="addSort(this)">
								<option value="0">请选择相册</option>
								<!--{loop $albums $value}-->
								<option value="$value[albumid]">$value[albumname]</option>
								<!--{/loop}-->
								<option value="addoption" style="color:red;">+新建相册</option>
							</select>
							<script src="source/js/script_upload.js" type="text/javascript"></script>
							<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<table cellspacing="4" cellpadding="4" width="100%" class="infotable" id="uchome-edit-album" style="display:none;">
		<tr>
			<td>
				选择相册: <select name="view_albumid" onchange="picView(this.value)">
					<option value="none">选择一个相册</option>
					<option value="0">默认相册</option>
					<!--{loop $albums $value}-->
					<option value="$value[albumid]">$value[albumname]</option>
					<!--{/loop}-->
				</select> (点击图片可以插入到内容中)
				<div id="albumpic_body"></div>
			</td>
		</tr>
	</table>
	<table cellspacing="4" cellpadding="4" width="100%" class="infotable">
		<tr>
			<td><input type="button" id="issuance" onclick="document.getElementById('threadbutton').click();" value="保存发布" class="submit" /></td>
		</tr>
	</table>
</div>

<!--{/if}-->

<!--{template footer}-->